#include <iostream>
#include <string>

class Father {
    public:
    Father(){}
    virtual ~Father(){
        std::cout << "delete Father" << std::endl;
    }
    
    virtual void showInfo(){
        std::cout << "Im Father" << std::endl;
    }
    private:
};

class Kid1:public Father {
    public:
    Kid1(){}
    ~Kid1(){
        std::cout << "delete Kid1" << std::endl;
    }
    virtual void showInfo(){
        std::cout << "Im Kid1" << std::endl;
    }
    private:
};

class Kid2:public Father {
    public:
    Kid2(){}
    ~Kid2(){
        std::cout << "delete Kid2" << std::endl;
    }
    virtual void showInfo(){
        std::cout << "Im Kid2" << std::endl;
    }
    private:
};

class simple_factory {
    public:
    ~simple_factory() {
        delete Fatherptr_;
    }
    Father* Interface(std::string name) {
        
        if(name == "Father") {
            Fatherptr_ = new Father;
        }
        else if (name == "Kid1") {
            Fatherptr_ = new Kid1;
        }
        else if (name == "Kid2") {
            Fatherptr_ = new Kid2;
        }
        return Fatherptr_;
    }
    private:
        Father* Fatherptr_ = nullptr;
};

int main() {
    std::cout << "Hello design patterns" << std::endl;
    simple_factory* sf = new simple_factory;
    sf->Interface("Kid2")->showInfo();
    delete sf;
    return 0;
}